<template>
  <div class="nmenuBox">
   <div class="header"></div>
   <div class="main">

    
  <avue-crud :data="data"
             :option="option"
             @refresh-change="refreshChange"
             @row-save="rowSave"
             @row-update="rowUpdate"
             @row-del="rowDel"></avue-crud>

         

   </div>
      </div>
</template>


<script>

//引入接口
import {ref,onMounted} from 'vue';
import {dg} from "@/api/index";
const list = ref([])
onMounted (async ()=>{
  const res = await dg()
  list.value= res.data.records
  // console.log(list,"+++++++");
})



export default {
  data () {
    return {
      data: [
        {
          id: 1,
          name: '产品管理',
          ur: '',
          one:"目录",
          two:"0",
        }, {
          id: 2,
          name: '门店管理',
          ur: '',
          one:"目录",
          two:"0",
        },{
          id:3,
          name:"会员管理",
          ur:"",
          one:"目录",
          two:"0",
        },{
          id:4,
          name:"订单管理",
          ur:"",
          one:"目录",
          two:"2",
        },{
          id:5,
          name:"系统管理",
          ur:'',
          one:"目录",
          two:"3",
        }
      ],
      option: {
        column: [
          {
            label: '名称',
            prop: 'name'
          }, {
            label: '图标',
            prop: 'ur'
          },{
            label:"类型",
            prop:"one"
          },{
            label:"排序号",
            prop:"two"
          },{
            label:"菜单URl",
            prop:"three"
          },{
            label:"授权标识",
            prop:"four"
          },{
            label:"操作",
            prop:"five"
          }

        ]
      },
    };
  },
  methods: {
    refreshChange () {
      this.$message.success('刷新回调');
    },
    rowSave (form, done, loading) {
      form.id = new Date().getTime();
      this.$message.success('模拟网络请求')
      setTimeout(() => {
        this.$message.success('关闭按钮等待');
        loading();
      }, 1000)
      setTimeout(() => {
        this.$message.success('新增数据' + JSON.stringify(form));
        done(form);
      }, 2000)
    },
    rowDel (form, index, done) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        done(form)
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => { });
    },
    rowUpdate (form, index, done, loading) {
      this.$message.success('模拟网络请求')
      setTimeout(() => {
        this.$message.success('关闭按钮等待');
        loading();
      }, 1000)
      setTimeout(() => {
        this.$message.success('编辑数据' + JSON.stringify(form) + '数据序号' + index);
        done(form);
      }, 2000)
    },
  }
}







</script>

<style>

</style>